import { ActiveBaseIcon } from "../activity/icon/ActiveBaseIcon";
import { ResFileConst } from "../../resource/ResFileConst";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ActiveIconChangeInfo } from "../../model/ActiveIconChangeInfo";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { SecTimer } from "../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../com/gengine/core/frame/TimerType";
import { RemainTimeTool } from "../award/RemainTimeTool";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class MultiExperienceHintBtn
    
    export  class MultiExperienceHintBtn extends ActiveBaseIcon
    {
        constructor(arg1: string=null)
        {
            super(arg1);
            arg1 = ResFileConst.MultiExpBtn;
            this.updateIconInfo();
            this.createTxt();
            return;
        }

        /* internal  */createTxt(): void
        {
            this._timeTxt = ObjCreate.createGTextField("", 0, 50, 60, 20, this, GlobalStyle.textFormatRed);
            return;
        }

        public /* override */ updateIconInfo(arg1: ActiveIconChangeInfo=null): void
        {
            super.updateIconInfo(arg1);
            _loadedBtn.addEventListener(MuiEvent.GLOADEDBUTTON_STYLE_COMPLETE, this.onLoadedHandler);
            return;
        }

        /* internal  */onLoadedHandler(arg1: MuiEvent): void
        {
            addChildAt(_loadedBtn, 0);
            return;
        }

        public setTime(arg1: int): void
        {
            if (this._secTimer != null) 
            {
                this._secTimer.repeatCount = arg1;
            }
            else 
            {
                this._secTimer = new SecTimer(1, arg1);
                this._secTimer.addListener(TimerType.ENTERFRAME, this.onTimerHandler);
                this._secTimer.addListener(TimerType.COMPLETE, this.onCompleteHandler);
            }
            this._secTimer.start();
            return;
        }

        /* internal  */onTimerHandler(arg1: SecTimer): void
        {
            this._timeTxt.htmlText = RemainTimeTool.getRemainTimeBySeconds(arg1.repeatCount);
            return;
        }

        /* internal  */onCompleteHandler(arg1: SecTimer): void
        {
            arg1.stop();
            arg1.isDelete = false;
            this.hide();
            return;
        }

        public updateMultiNum(arg1: int): void
        {
            if (arg1 <= 0) 
            {
                if (_imageBmp && _imageBmp.parent) 
                {
                    removeChild(_imageBmp);
                }
                if (_multipTxt) 
                {
                    _multipStr = "";
                    _multipTxt.htmlText = "";
                }
                return;
            }
            if (_imageBmp == null) 
            {
                _imageBmp = new GImageBitmap(ImagesConst.ActiveMultipleBg, 25, 3);
            }
            addChild(_imageBmp);
            if (_multipTxt == null) 
            {
                _tf = new GTextFormat(FontUtil.stXingkaiName, 14, 16776960, null, null, null, null, null, flash.text.TextFieldAutoSize.RIGHT);
                _multipTxt = ObjCreate.createGTextField("", 20, 0, 40, 20, this, _tf);
            }
            addChild(_multipTxt);
            _multipStr = "×" + arg1;
            _multipTxt.text = _multipStr;
            return;
        }

        /* internal */ /* var */_secTimer: SecTimer;

        /* internal */ /* var */_timeTxt: GTextFiled;
    }
